package com.unit.testng.parameter;


import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.lang.reflect.Method;


/**
 * @author bigFish
 * @Title: DataProvider参数化
 */
public class DataPorviderTest {
    @Test(dataProvider = "data")
    public void testDataProvider(String name,Integer age){
        System.out.println("name="+name+";age="+age);
    }

    @DataProvider(name = "data")
    public Object[][] providerDate(){
        return new Object[][]{
                {"张三",10},
                {"李四",20},
                {"王五",50}
        };
    }

    @Test(dataProvider = "method")
    public void test1(String name , int age){
        System.out.println("this is Test1:"+"name="+name+";age="+age);
    }

    @Test(dataProvider = "method")
    public void test2(String name , int age){
        System.out.println("this is Test2:"+"name="+name+";age="+age);
    }

    @DataProvider(name = "method")
    public Object[][] methodData(Method method){
        Object [] [] o = null;
        if("test1".equals(method.getName())){
            o=new Object[][]{
                    {"我是test案例1",111111}
            };
        }else if ("test2".equals(method.getName())){
            o=new Object[][]{
                    {"我是test案例2",22222}
            };
        }
        return o;
    }
}
